﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class ProductDAL : SqlDataProvider
	{

		#region[Product_GetbyAll]
		public DataTable Product_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_Product_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[Product_GetbyId]
		public DataTable Product_GetById(string Data)
		{
			using (var cmd = new SqlCommand("sp_Product_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[Product_GetbyTop]
		public DataTable Product_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_Product_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[Product_Insert]
		public void Product_Insert(ProductInfo Data)
		{
			using (var cmd = new SqlCommand("sp_Product_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Name", Data.Name));
				cmd.Parameters.Add(new SqlParameter("@Detail", Data.Detail));
				cmd.Parameters.Add(new SqlParameter("@Price", Data.Price));
				cmd.Parameters.Add(new SqlParameter("@Image", Data.Image));
				cmd.Parameters.Add(new SqlParameter("@HSX", Data.HSX));
				cmd.Parameters.Add(new SqlParameter("@Date", Data.Date));
				cmd.Parameters.Add(new SqlParameter("@Order", Data.Order));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.Parameters.Add(new SqlParameter("@GroupProduct_Id", Data.GroupProduct_Id));
				cmd.Parameters.Add(new SqlParameter("@Os", Data.Os));
				cmd.Parameters.Add(new SqlParameter("@Processor", Data.Processor));
				cmd.Parameters.Add(new SqlParameter("@Memory", Data.Memory));
				cmd.Parameters.Add(new SqlParameter("@HD", Data.HD));
				cmd.Parameters.Add(new SqlParameter("@VM", Data.VM));
				cmd.Parameters.Add(new SqlParameter("@VC", Data.VC));
				cmd.Parameters.Add(new SqlParameter("@SC", Data.SC));
				cmd.Parameters.Add(new SqlParameter("@DirectX", Data.DirectX));
				cmd.Parameters.Add(new SqlParameter("@Age", Data.Age));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[Product_Update]
		public void Product_Update(ProductInfo Data)
		{
			using (var cmd = new SqlCommand("sp_Product_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				cmd.Parameters.Add(new SqlParameter("@Name", Data.Name));
				cmd.Parameters.Add(new SqlParameter("@Detail", Data.Detail));
				cmd.Parameters.Add(new SqlParameter("@Price", Data.Price));
				cmd.Parameters.Add(new SqlParameter("@Image", Data.Image));
				cmd.Parameters.Add(new SqlParameter("@HSX", Data.HSX));
				cmd.Parameters.Add(new SqlParameter("@Date", Data.Date));
				cmd.Parameters.Add(new SqlParameter("@Order", Data.Order));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.Parameters.Add(new SqlParameter("@GroupProduct_Id", Data.GroupProduct_Id));
				cmd.Parameters.Add(new SqlParameter("@Os", Data.Os));
				cmd.Parameters.Add(new SqlParameter("@Processor", Data.Processor));
				cmd.Parameters.Add(new SqlParameter("@Memory", Data.Memory));
				cmd.Parameters.Add(new SqlParameter("@HD", Data.HD));
				cmd.Parameters.Add(new SqlParameter("@VM", Data.VM));
				cmd.Parameters.Add(new SqlParameter("@VC", Data.VC));
				cmd.Parameters.Add(new SqlParameter("@SC", Data.SC));
				cmd.Parameters.Add(new SqlParameter("@DirectX", Data.DirectX));
				cmd.Parameters.Add(new SqlParameter("@Age", Data.Age));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[Product_Delete]
		public void Product_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_Product_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}